package org.sith.taskrunner.ejb;

import org.sith.taskrunner.api.task.Task;
import org.sith.taskrunner.api.toolkit.DefaultTaskToolkit;
import org.sith.taskrunner.api.toolkit.TaskToolkit;
import org.sith.taskrunner.api.TaskToolkitDescription;
import org.sith.taskrunner.ejb.tasks.SumTask;
import org.sith.taskrunner.ejb.transformers.StringSumDataTransformer;
import org.sith.taskrunner.ejb.transformers.SumResultTransformer;

public class SumTaskToolkit extends DefaultTaskToolkit<SumTask, StringSumDataTransformer, SumResultTransformer, TaskToolkitDescription<String>> {

    @Override
    public SumTask createTaskInstance() {
        return new SumTask();
    }

    private static class StringTaskToolkitDescription implements TaskToolkitDescription<String> {
        private final static String desc = "Task for adding integers. Input data must be a white space separated integers. Input result is a sum value";
        private static final StringTaskToolkitDescription instance = new StringTaskToolkitDescription();

        private StringTaskToolkitDescription() {
        }

        @Override
        public String getDescription() {
            return desc;
        }


        public static StringTaskToolkitDescription getInstance() {
            return instance;
        }
    }

    @Override
    public StringSumDataTransformer createInputDataTransofrmer() {
        return new StringSumDataTransformer();
    }

    @Override
    public SumResultTransformer createResultTransformer() {
        return new SumResultTransformer();
    }

    @Override
    public TaskToolkitDescription<String> createToolkitDescription() {
        return StringTaskToolkitDescription.getInstance();
    }
}
